/**
 * 
 _query_list(__BASE_PATH +'page/developAppExt/endCards', '#tagContent0' ,'pagination',{
		rows : 3,
		page : 1,
		isSelfDevCard:"1"
	},  0,__TMPL_HTML,'POST');
 */

//查询主体
var _query_list = function(requst_url,_item_wrap,post_data,_tab_index,__TMPL_HTML,_param_data){
	var callback_page = _param_data.callback_page;
	var callback_head = _param_data.callback_head;
	var change_select_data = _param_data.change_select_data;
	var callback_change_css = _param_data.callback_change_css;
	var default_data = _param_data.default_data;
	var method = _param_data.method;
	method = method || "POST";
	_item_wrap.empty();
	_item_wrap.append('<div class="_item" style="text-align:center;padding:10px;"><span class="icon_loading"></span></div>');
	
	var fnc = null;
	if("POST" == method){
		fnc = $.post;
	}else{
		fnc = $.get;
	}
	
	fnc(
		requst_url,
		post_data,
		function(result){
			
			_item_wrap.empty();
			if(!result || !result.rows ||result.rows.length < 1){
				//$('<div class="_item" style="text-align: center;">no more result..</div>').appendTo(_item_wrap);
				if(callback_page && typeof callback_page == 'function'){
					callback_page(0, {current_page:0,next_text : "下一页",prev_text : "上一页"});    				
				}
				return false;
			}
			
			if (result.state != 200) {
				//$('<div class="_item" style="text-align: center;">failed to query : '+result.message+'</div>').appendTo(_item_wrap);
				if(callback_page && typeof callback_page == 'function'){
					callback_page(0, {current_page:0,next_text : "下一页",prev_text : "上一页"});  				
				}
				return false;
			} 
			

			if(callback_head && typeof callback_head == 'function'){
				callback_head();    				
			}
			
			var rows = result['rows'];
			for(var i in rows){
				var item_data = rows[i];
				item_data["_tab_index"] = _tab_index;
				//可以加入默认值的处理  {'sex':{0:'男',1:'女'}}
				if(change_select_data){
					for(var name in change_select_data){
						var real_value = item_data[name];
						if(real_value && _is_not_empty(real_value)){
							item_data[name] = change_select_data[name][real_value];
						}
					}
				}
				if(default_data){
					for(var name in default_data){
						var real_value = item_data[name];
						if(_is_empty(real_value)){
							item_data[name] = default_data[name];
						}
					}
				}
				//item_data["_tab_index"] = _tab_index;
				//item_data["cardNotes"] = _def_value(item_data["cardNotes"],"N/A");
				//if(_is_empty(item_data["cardName"])){
					//item_data["cardName"] = _def_value(item_data["cardTitle"],"N/A");
				//}
				var tmpl_html = _renderTemplate(__TMPL_HTML,item_data);
				
				if(callback_change_css && typeof callback_change_css == 'function'){
					//偶数列加入样式
					tmpl_html = callback_change_css(tmpl_html,i);
				}
				var $tmpl_html = $(tmpl_html);
			    //可以加入额外处理
				_item_wrap.append($tmpl_html);
			}
			
			var opt_init = {
					next_text : "下一页",
					prev_text : "上一页",
					link_to : "javascript:void(0);",
					callback : function(current_page, _this){
						if(post_data.page === current_page + 1){
							return false;
						}
						post_data.page = current_page + 1;
						_query_list(requst_url,_item_wrap,post_data,_tab_index,__TMPL_HTML,_param_data);
					},
					current_page : post_data.page - 1,
					items_per_page : post_data.rows
			};
			if(callback_page && typeof callback_page == 'function'){
				callback_page(result['total'], opt_init);    				
			}
			
	},"JSON");
};